﻿using System;
using System.IO;

namespace FotoAlbum.Sort
{
    /// <summary>
    /// File Info Compare class.
    /// </summary>
    public class FICompare : IComparable
    {
        public static SortType Type { get; set; }
        public static SortOrder Order { get; set; }

        public string Name { get { return fi.Name; } }
        public string Path { get { return fi.FullName; } }

        private FileInfo fi;

        public FICompare(FileInfo fi)
        {
            this.fi = fi;
        }

        public int CompareTo(object obj)
        {
            if (obj == null)
                return -1;

            FICompare comp = obj as FICompare;

            switch (Type)
            {
                case SortType.DateOfCreation:
                    return comp.fi.CreationTime.CompareTo(fi.CreationTime);

                case SortType.Filesize:
                    return comp.fi.Length.CompareTo(fi.Length);

                default:
                case SortType.Name:
                    return comp.fi.Name.CompareTo(fi.Name);
            }
        }
    }
}
